Ext.define('Admin.view.system.msg.Msg', {
	extend: 'Admin.ux.PageGrid',
    xtype: 'msg-view',
    title: '系统消息',
    viewModel: {
       stores: { 
	        data: {
	            type: 'msg-store',
	            autoLoad: true
	   		 }
	    },
	    data:{
	    	batchRemoveAction : true,
	    	batchRemoveText:'批量删除(0)',
	    	batchConfirmAction : true,
	    	batchConfirmText:'确认消息(0)'
	    }
    },
    controller:'msg',
    listeners: {
        selectionchange: 'onSelectionChange'
    },
	columnLines : false,
 	columns: [
	 	{ xtype: 'rownumberer',width:'5%'},
	 	{ text: '消息标题', width:'35%',dataIndex: 'msg_title',flex:2,renderer:function(value, meta, record){
	 		if(value){
           	  meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.get('msg_content')) + '"';
    		}
	 		 return value;
	 	}}, 
	 	
	 	{ text: '状态', width:'5%',dataIndex: 'status',renderer:function(v){
	 		if(v=='0'){
	 			return "<center><font color='#CC9900' data-qtip='待处理'><b><i class='x-fa fa-share-square-o'></i></b></font></center>";
	 		}else if(v=='1'){
	 			return  "<center><font color='#339933'  data-qtip='已完成'><b><i class='x-fa fa-check-square'></i></b></font></center>";
	 		}
	 		
	 	}}, 
	 	{ text: '级别', width:'7%',dataIndex: 'level',renderer:function(v){
	 		if(v=='0'){
	 			return "<font color='#999999'  data-qtip='普通'>普通</font>";
	 		}else{
	 			return  "<font color='#FF6600'  data-qtip='警告'><b>紧急</b></font>";
	 		}
	 	}}, 
	 	{ width:'15%',text: '处理时间', dataIndex: 'action_time',renderer:function(value, meta, record){
		 		if(value==null){
		 			return  "<font color='#FF6600'><b>未处理</b></font>";
		    	}
			 	return value;
		 	}}, 
	 	{ xtype:'gridcolumnview', width:'12%',text: '发布者', dataIndex: 'uid'}, 
	    {
	        menuDisabled: true,
	        sortable: false,
	        xtype: 'actioncolumn',
	        width: 100,
	        text:'操作',
	        width:'15%',
	        items: [
					{
					    iconCls: 'icon-cron',
					    tooltip: '设置定时器',
					    handler: 'CronAction'
					},
					'-',
					{
					    iconCls: 'icon-send-email',
					    tooltip: '发送通知',
					    handler: 'SendAction'
					},
					'-',
					{
					    iconCls: 'array-grid-buy-col',
					    tooltip: '编辑',
					    handler:'editAction'
					},
					 '-',
			        {
			             iconCls: 'array-grid-sell-col',
			             tooltip: '删除',
			             handler: 'removeAction'
			        }
			]
	    }
	],
	
	plugins: [{
        ptype: 'rowexpander',
        rowBodyTpl : new Ext.XTemplate('<p>{msg_content}</p>',{})
    }],
    tbar:[
		{
			text:'新建消息',
			iconCls: 'x-fa fa-plus',
			handler:'addAction'
		},
		{
    		iconCls: 'x-fa fa-minus',
	    	handler:'batchRemoveAction',
	    	bind:{
    			disabled :'{batchRemoveAction}',
    			text:'{batchRemoveText}'
    		}
    	},
		{
    		iconCls: 'icon-check',
	    	handler:'batchConfirmAction',
	    	bind:{
    			disabled :'{batchConfirmAction}',
    			text:'{batchConfirmText}'
    		}
    	},
		'->',
    	{
			xtype : 'keysearchfield'
		}
	]
});
